a = {'zero' : 0, 'one' : 1, 'two' : 2, 'three' : 3, 'four' : 4, 'five' : 5, 'six' : 6, 'seven' : 7, 'eight' : 8, 'nine' : 9}
try:
    n = input()
    b = n.split(" ")
    m = " "
    c = []
    for i in b:
        c.append(str(a[i]))
    z = "".join(c)
    if 100<int(z)<=1000:
        def is_prime(n):
            if not n%2:
                return n == 2
            d=3
            while d*d<=n and n %d :
                d+=2
            return  d*d>n
        num = int(z)
        tmp = abs(num-2)
        res = 2
        k = 3
        while True:
            if is_prime(k):
                t = abs(num-k)
                if t<tmp:
                    tmp=t
                    res = k
                else:
                    print(res)
                    break
            k+=2
    else:
        print("Wrong input")
        
        
except Exception:
    print("Wrong input")
